﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace FrameworkDesign.Example
{
    public class Game : MonoBehaviour
    {
        private void Awake()
        {
            GameStartEvent.Register(OnGameStart);
            GameModel.killedEnemyCount.onValueChanged += OnKillEnemy;

        }

        private void OnKillEnemy(int killCount)
        {
   
            if (killCount == 10)
            {
                GamePassEvent.Trigger();
            }
        }

        private void OnGameStart()
        {
            transform.Find("Enemies").gameObject.SetActive(true);
        }

        // Start is called before the first frame update
        void Start()
        {

        }

        // Update is called once per frame
        void Update()
        {
           
        }


        private void OnDestroy()
        {
            GameStartEvent.UnRegister(OnGameStart);
            GameModel.killedEnemyCount.onValueChanged -= OnKillEnemy;
            
        }
    }

}
